﻿Public Class cTipoIva
    Private ldaTipoIva As lbGlobalcom.dsContabilidadTableAdapters.CON_TIPOIVATableAdapter
    Private lDtTipoIva As lbGlobalcom.dsContabilidad.CON_TIPOIVADataTable
    Private lDrTipoIva As lbGlobalcom.dsContabilidad.CON_TIPOIVARow

    Sub New(ByVal TipoIva As String)
        ldaTipoIva = New lbGlobalcom.dsContabilidadTableAdapters.CON_TIPOIVATableAdapter
        lDtTipoIva = New lbGlobalcom.dsContabilidad.CON_TIPOIVADataTable
        Try
            lDtTipoIva = ldaTipoIva.GetDataByIdTipoIva(TipoIva)
            If lDtTipoIva.Rows.Count <> 0 Then
                lDrTipoIva = lDtTipoIva.Rows(0)
            Else
                Throw New Exception("No existe IVA en tabla para este tipo de iva")
            End If
        Catch ex As Exception
            cError.SalvaError(ex, "Samuel")
            Throw ex
        End Try

    End Sub

    Public ReadOnly Property IdTipoIva() As String
        Get
            Return lDrTipoIva.IDTIPOIVA
        End Get

    End Property

    Public ReadOnly Property Descripcion() As String
        Get
            Return lDrTipoIva.DESCRIPCION
        End Get

    End Property

    Public ReadOnly Property PorIva() As Decimal
        Get
            Return lDrTipoIva.PORIVA
        End Get
    End Property

    Protected Overrides Sub Finalize()
        lDrTipoIva = Nothing
        lDtTipoIva = Nothing
        ldaTipoIva = Nothing
    End Sub
End Class
